
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import store from 'strore/store.js'
import { $http } from '@escook/request-miniprogram'

Vue.config.productionTip = false

App.mpType = 'app'

uni.$http = $http
$http.baseUrl = 'https://api-hmugo-web.itheima.net'
// 请求开始之前做一些事情
$http.beforeRequest = function (options) {
  uni.showLoading({
    title: '数据加载中...',
  })
  if (options.url.indexOf('/my/')!== -1) {
    options.header={
      "Authorization" : store.state.m_cart.token
    }
  }
}
// 请求完成之后做一些事情
$http.afterRequest = function () {
  uni.hideLoading()
}
// 封装一个如果请求错误之后做的事
uni.$showMsg = function(title='请求失败,请稍后再试',duration=1500){
    uni.showLoading({
      title,
      duration,
      icon: 'none',
    })
}
const app = new Vue({
    ...App,
    store
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif